*------------- Upper-Body Strength and Political Egalitarianism: Twelve Conceptual Replications ------------------------------------*
*----------------------------------------------------- STUDY 11 --------------------------------------------------------------------*

*-------------------------------------------------- Background variables -----------------------------------------------------------*

** Gender
tab female
tab male

** Age
summ age

** Education
tab education_us

** Income (household income)
tab income_hh_us


*------------------------------------------- Physical Strength Variables -------------------------------------------------------------*
summ strength_handgrip1 strength_handgrip2 strength_chest1 strength_chest2 strength_handgrip3 strength_chest3

recode strength_handgrip1 strength_handgrip2 strength_chest1 strength_chest2 strength_handgrip3 strength_chest3 (.2 .6 .8 999 = .)
//This recoding excludes subject with id = 2350 - who accordring to the RA also reported to suffer from Parkinson's disease - from the sample.

factor strength_handgrip1 strength_handgrip2 strength_chest1 strength_chest2, pcf
//Result: One dimension

* Dynamometer (handgrip) - creates variable based on highest value across the two trials
egen hand_strength = rowmax(strength_handgrip1 strength_handgrip2 strength_handgrip3)

* Reversed dynamometer (chest)- creates variable based on highest value across the two trials
egen chest_strength = rowmax(strength_chest1 strength_chest2 strength_chest3)


** Creates compopsite formidability variable
factor hand_strength chest_strength, pcf
predict physstrength

bys female: summ physstrength
hist physstrength if female == 1
hist physstrength if male == 1


** Recodes formidability variable to 0-1 scale reflecting min. and max. values for females and males, respectively
summ physstrength if female == 1
generate physmorph_factor = (physstrength-(r(min)))/(r(max)-r(min)) if female == 1

summ physstrength if male == 1
replace physmorph_factor = (physstrength-(r(min)))/(r(max)-r(min)) if male == 1

bys female: summ physmorph_factor



*--------------------------------------------------- Dependent Variables ------------------------------------------------------*
**** Economic Conservatism scale
tab1 presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5

recode presvy_q47_1 presvy_q47_2 presvy_q47_3  (6=.) (5=1) (4=2) (2=4) (1=5)
recode presvy_q47_4 presvy_q47_5 (6=.)

alpha presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5

egen ecocon_coded = rowmean(presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5)

* Recodes variable to 0-1 variable reflecting min. and max. values for females and males, respectively
summ ecocon_coded if female == 1
generate economic_conservatism = (ecocon_coded-(r(min)))/(r(max)-r(min)) if female == 1

summ ecocon_coded if male == 1
replace economic_conservatism = (ecocon_coded-(r(min)))/(r(max)-r(min)) if male == 1

bys female: summ economic_conservatism

 
**** Social Dominance Orientation scale
tab1 bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8

recode bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_7 bkgrnd_q9_8 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)

egen sdo_coded = rowmean(bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8)

alpha bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8

*Recodes to 0-1 scale for observed min. and max. values for females and males, respectively
summ sdo_coded if female == 1
generate SDO = (sdo_coded-(r(min)))/(r(max)-r(min)) if female == 1

summ sdo_coded if male == 1
replace SDO = (sdo_coded-(r(min)))/(r(max)-r(min)) if male == 1

bys female: summ SDO


*** SDO sub-dimensions - measured on 0-1 scales reflecting min. and max. values for females and males, respectively
* SDO-D
egen sdo_d = rowmean(bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4)

alpha bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4

summ sdo_d if female == 1
generate SDO_D = (sdo_d-(r(min)))/(r(max)-r(min)) if female == 1

summ sdo_d if male == 1
replace SDO_D = (sdo_d-(r(min)))/(r(max)-r(min)) if male == 1

bys female: summ SDO_D

* SDO-E
egen sdo_e = rowmean(bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8)

alpha bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8

summ sdo_e if female == 1
generate SDO_E = (sdo_e-(r(min)))/(r(max)-r(min)) if female == 1

summ sdo_e if male == 1
replace SDO_E = (sdo_e-(r(min)))/(r(max)-r(min)) if male == 1

bys female: summ SDO_E


*** Rightwing Authritarianism scale
tab1 presvy_q58_1_us presvy_q58_2_us presvy_q58_3_us presvy_q58_4_us presvy_q58_7_us presvy_q58_9_us presvy_q58_10_us

recode presvy_q58_1_us presvy_q58_2_us presvy_q58_10_us (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)

egen rwa_coded = rowmean(presvy_q58_1_us presvy_q58_2_us presvy_q58_3_us presvy_q58_4_us presvy_q58_7_us presvy_q58_9_us presvy_q58_10_us)

alpha presvy_q58_1_us presvy_q58_2_us presvy_q58_3_us presvy_q58_4_us presvy_q58_7_us presvy_q58_9_us presvy_q58_10_us

* Recoded to 0-1 scale for observed min and max values for females and males, respectively
summ rwa_coded if female == 1
generate RWA = (rwa_coded-(r(min)))/(r(max)-r(min)) if female == 1

summ rwa_coded if male == 1
replace RWA = (rwa_coded-(r(min)))/(r(max)-r(min)) if male == 1
bys female: summ RWA


*------------------------------------------------------ CONTROL VARIABLES ----------------------------------------------------------*
** Personality measures: Big Five traits
tab1 presvy_q2_1 presvy_q2_2 presvy_q2_3 presvy_q2_4 presvy_q2_5 presvy_q2_6 presvy_q2_7 presvy_q2_8 presvy_q2_9 presvy_q2_10
recode presvy_q2_2 presvy_q2_6 presvy_q2_8 presvy_q2_9 presvy_q2_10 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)

* Creates variables for each of the five traits
egen openness = rowmean(presvy_q2_5 presvy_q2_10)

egen conscientious = rowmean(presvy_q2_3 presvy_q2_8)

egen agreeable = rowmean(presvy_q2_2 presvy_q2_7)

egen extraversion = rowmean(presvy_q2_1 presvy_q2_6)

egen neuroticism = rowmean(presvy_q2_4 presvy_q2_9)

*Recodes each of the five trait variables to 0-1 scale for observed min and max values for females and males, respectively
* Openness
summ openness if female == 1
generate open01 = (openness-(r(min)))/(r(max)-r(min)) if female == 1

summ openness if male == 1
replace open01 = (openness-(r(min)))/(r(max)-r(min)) if male == 1

* Conscientiousness
summ conscientious if female == 1
generate consc01 = (conscientious-(r(min)))/(r(max)-r(min)) if female == 1

summ conscientious if male == 1
replace consc01 = (conscientious-(r(min)))/(r(max)-r(min)) if male == 1

* Agreeableness
summ agreeable if female == 1
generate agree01 = (agreeable-(r(min)))/(r(max)-r(min)) if female == 1

summ agreeable if male == 1
replace agree01 = (agreeable-(r(min)))/(r(max)-r(min)) if male == 1

* Extraversion
summ extraversion if female == 1
generate extra01 = (extraversion-(r(min)))/(r(max)-r(min)) if female == 1

summ extraversion if male == 1
replace extra01 = (extraversion-(r(min)))/(r(max)-r(min)) if male == 1

* Neuroticism
summ neuroticism if female == 1
generate neuro01 = (neuroticism-(r(min)))/(r(max)-r(min)) if female == 1

summ neuroticism if male == 1
replace neuro01 = (neuroticism-(r(min)))/(r(max)-r(min)) if male == 1

** Summarizes each of the five traits for males and females, respectively
bys female: summ open01 consc01 agree01 extra01 neuro01


**** Network content variables
tab1 presvy_q17 presvy_q21

* Unemployment
clonevar unemployment_experience = presvy_q21
label define unemplLB 1 "currently - self or near family" 2 "has been - self or near family" 3 "no - neither self nor near family" 4 "don't want to answer"
label values unemployment_experience unemplLB
tab unemployment_experience

* African-American friends
clonevar black_friends = presvy_q17
label define blackfriendsLB 1 "None" 2 "Just one" 3 "A few" 4 "Some" 5 "Many" 6 "Do not wish to answer"
label values black_friends blackfriendsLB
tab black_friends



**** Socio-Economic Status scale based on household income and education
** Education
summ education
* Creates standardized variable
egen std_education = std(education)

** Income
* Averaging across household and personal income
summ income_hh
* Creates standardized variable
egen std_income = std(income_hh)


**** Creates composite SES scale
summ std_education std_income
egen SES_scale = rowmean(std_education std_income)

* Recodes to 0-1 scale reflecting min and max observed values for females and males, respectively
summ SES_scale if female == 1
generate SES_scale01 = (SES_scale-(r(min)))/(r(max)-r(min)) if female == 1

summ SES_scale if male == 1
replace SES_scale01 = (SES_scale-(r(min)))/(r(max)-r(min)) if male == 1


*--------------------------------------------------- DESCRIPTIVES ----------------------------------------------------------------*
* Age and gender
summ age if physmorph_factor !=.
tab female if physmorph_factor !=. & age !=.

* Formidability
bys female: summ physmorph_factor if age !=.

* Social Dominance Orientation
alpha bkgrnd_q9_1 bkgrnd_q9_2 bkgrnd_q9_3 bkgrnd_q9_4 bkgrnd_q9_5 bkgrnd_q9_6 bkgrnd_q9_7 bkgrnd_q9_8 if physmorph_factor !=. & age !=.
bys female: summ SDO if physmorph_factor !=. & age !=.

* Economic Conservatism
alpha presvy_q47_1 presvy_q47_2 presvy_q47_3 presvy_q47_4 presvy_q47_5 if physmorph_factor !=. & age !=.
bys female: summ economic_conservatism if physmorph_factor !=. & age !=.

* Rightwing Authoritarianism
alpha presvy_q58_1_us presvy_q58_2_us presvy_q58_3_us presvy_q58_4_us presvy_q58_7_us presvy_q58_9_us presvy_q58_10_us if physmorph_factor !=. & age !=.
bys female: summ RWA if physmorph_factor !=. & age !=.

* Big Five personality traits
bys female: summ open01 consc01 extra01 agree01 neuro01 if physmorph_factor !=. & age !=.

* SES scale
bys female: summ SES_scale01 if physmorph_factor !=. & age !=.


*------------------------------------------------------- Analyses --------------------------------------------------------------*
*** Does Physical Strength predict SDO?

*Females
reg SDO physmorph_factor c.age c.education_us if female == 1

*Males
reg SDO physmorph_factor c.age c.education_us if male == 1


*** Does Physical Strength predict SDO-subdimensions?
** SDO-D
* Females
reg SDO_D physmorph_factor c.age c.education_us if female == 1

* Males
reg SDO_D physmorph_factor c.age c.education_us if male == 1

** SDO-E
* Females
reg SDO_E physmorph_factor c.age c.education_us if female == 1

* Males
reg SDO_E physmorph_factor c.age c.education_us if male == 1


*** Does Physical Strength predict RWA?
* Females
reg RWA physmorph_factor c.age c.education_us if female == 1

* Males
reg RWA physmorph_factor c.age c.education_us if male == 1


*** Does Physical Strength predict Economic Conservatism?
* Females
reg economic_conservatism physmorph_factor c.age c.education_us if female == 1

* Males
reg economic_conservatism physmorph_factor c.age c.education_us if male == 1




**** Mediation anlayses: Does Physical Strength predict Economic Conservatism THROUGH SDO?
** Males
* Path: Physical Strength --> SDO --> Economic Conservatism
sem (age education_us physmorph_factor -> SDO if male==1) ///
	(age education_us physmorph_factor SDO -> economic_conservatism), nocapslatent
	
estat teffects
estat gof, stats(all)


** Females
* Path: Physical Strength --> SDO --> Economic Conservatism
sem (age education_us physmorph_factor -> SDO if female==1) ///
	(age education_us physmorph_factor SDO -> economic_conservatism), nocapslatent
	
estat teffects
estat gof, stats(all)



**** Robustness analyses: Controlling for Big Five personality measures
** Prediction of SDO
* Female subjects
reg SDO physmorph_factor c.age c.education_us open01 consc01 extra01 agree01 neuro01 if female==1

* Male subjects
reg SDO physmorph_factor c.age c.education_us open01 consc01 extra01 agree01 neuro01 if male==1


*** Prediction of Economic Conservatism 
* Female subjects
reg economic_conservatism physmorph_factor c.age c.education_us open01 consc01 extra01 agree01 neuro01 if female==1

* Male subjects
reg economic_conservatism physmorph_factor c.age c.education_us open01 consc01 extra01 agree01 neuro01 if male==1


**** Robustness analyses: Controlling for content of social network
** Prediction of SDO
* Female subjects
reg SDO physmorph_factor c.age c.education_us ib(3).unemployment_experience ib(1).black_friends if female == 1

* Male subjects
reg SDO physmorph_factor c.age c.education_us ib(3).unemployment_experience ib(1).black_friends if male == 1


** Prediction of Economic Conservatism 
* Female subjects
reg economic_conservatism physmorph_factor c.age c.education_us ib(3).unemployment_experience ib(1).black_friends if female == 1

* Male subjects
reg economic_conservatism physmorph_factor c.age c.education_us ib(3).unemployment_experience ib(1).black_friends if male == 1


**** Robustness analyses: Does socio-economic status moderate the relationship between physical strength and the dependent variables (SDO & Econ. Cons.)
** Prediction of SDO
* Female subjects
reg SDO c.physmorph_factor##c.SES_scale01 c.age c.education_us if female == 1

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Male subjects
reg SDO c.physmorph_factor##c.SES_scale01 c.age c.education_us if male == 1

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

** Prediction of Economic Conservatism 
* Female subjects
reg economic_conservatism c.physmorph_factor##c.SES_scale01 c.age c.education_us if female == 1

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Male subjects
reg economic_conservatism c.physmorph_factor##c.SES_scale01 c.age c.education_us if male == 1

margins, dydx(physmorph_factor) at(SES_scale01=(0 (0.05) 1.0))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(Socio-Economic Status) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


**** Robustness analyses: Does formidability relate stronger to anti-egalitarianism among younger than older males? (moderation by respondent age?)
** Males
* Prediction of SDO
reg SDO c.physmorph_factor##c.age c.education_us if male == 1

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Prediction of Economic Conservatism
reg economic_conservatism c.physmorph_factor##c.age c.education_us if male == 1

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


** Females
* Prediction of SDO
reg SDO c.physmorph_factor##c.age c.education_us if female == 1

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Prediction of Economic Conservatism
reg economic_conservatism c.physmorph_factor##c.age c.education_us if female == 1

margins, dydx(physmorph_factor) at(age=(18 (1) 70))
marginsplot, recastci(rline) ciopts(lpattern(dash)) recast(line) yline(0) xlabel(#10) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


***** Does the insignificant interactions between age and Physical Strength replicate using a dichotomous age variable (below median age vs. above median age)
** Creates dichotomous age variable
* Males
summ age if male == 1, detail
generate age_medsplit =.
replace age_medsplit = 1 if age > 46 & male == 1
replace age_medsplit = 0 if age <= 46 & male == 1
* Females
summ age if female == 1, detail
replace age_medsplit = 1 if age > 51 & female == 1
replace age_medsplit = 0 if age <= 51 & female == 1


**** Formidability X age interactions using dichotomous age variable:
** Males
* SDO
reg SDO c.physmorph_factor##i.age_medsplit c.education_us if male == 1

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Economic Conservatism
reg economic_conservatism c.physmorph_factor##i.age_medsplit c.education_us if male == 1

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)


** Females
* SDO
reg SDO c.physmorph_factor##i.age_medsplit c.education_us if female == 1

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)

* Economic Conservatism
reg economic_conservatism c.physmorph_factor##i.age_medsplit c.education_us if female == 1

margins, dydx(physmorph_factor) at(age_medsplit=(0 (1) 1))
marginsplot, recastci(rcap) ciopts(lpattern(dash)) recast(bar) yline(0) xlabel(#2) ///
xtitle(age) ytitle(Marg. effect of composite strength variable) title("") scheme(s2mono)
